import JSEncrypt from 'jsencrypt'
// 公钥
const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCNfcV+KcSNFZDJat4c1IHkDZNmqJ9F9SVTq30S4X3RAiZgLLeULHvEo12zEZGUqN/7pt55E3jVipTS76V8VNKJUj7phakUH/WErJjfdKaU4jD/Vkkx+anwCG14+jDRashs4E91CG0M+Bmq0KZeqfi086dlr8C53ONBVQDV/PQuRwIDAQAB'

// 私钥
const privateKey = 'MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAI19xX4pxI0VkMlq3hzUgeQNk2aon0X1JVOrfRLhfdECJmAst5Qse8SjXbMRkZSo3/um3nkTeNWKlNLvpXxU0olSPumFqRQf9YSsmN90ppTiMP9WSTH5qfAIbXj6MNFqyGzgT3UIbQz4GarQpl6p+LTzp2WvwLnc40FVANX89C5HAgMBAAECgYAtHrVy9RjTsNPaFzU7Vl0Rf27I5u7bnUBI/T/GXJgFpbzdIIVuP/08CKihqPGWyX+bvWvmiloXJrksxvUrv9TfLtKe21b1KEgHiqS7rhv7MGkCfXbv5mcoZl5BZuSVCyKR3gXROVrNa0o5ax2kUt/UPRMbHoSSLrUYHPrEuCtSGQJBAPDX+CymRAttMENNZtaK7pXvRNRLcnrDH2ONMWjFFEqa6PjeHbZKkUEf1XLcIplQWrVez0zf5JOzpF3Ma+3PbbUCQQCWZTgy2z2+/iWDLKXR3abbRzetsRlgqDw8epA96r3A/hXo19EENClyW/Rj0OFzM7yn9G6IBa7YCPTOHAeJv0mLAkA/caT+ng3utKSyFgGxIogXFyCajAVsMVpjbx5E6yWdQZF9fYV2L85zyV8BEtxKZtB+VqtlJNWh0wDJdMA5tRrBAkAzURJd+AUXmGyAV8m01GbMx34uHBHGs2DqWf/BwMlCgvBC5PEC+DF0PgAj1vA2eN7UiEj2zMmeGWA+u72uuMCFAkA1ry9SGuEbKET9TqvZNl0agNN5NpTtH679+iMXNNdapT8L0WGy1CyD691TNgqUKrq6f2BF0T4H3bajA1ouHlwE'

// rsa 加密
export const rsaEncrypt = (value) => {
  const encryptor = new JSEncrypt()
  // 用公钥加密
  encryptor.setPublicKey(publicKey)
  return encryptor.encrypt(value)
}

// rsa 解密
export const rsaDecryption = (value) => {
  const encryptor = new JSEncrypt()
  // 用私钥解密
  encryptor.setPrivateKey(privateKey)
  return encryptor.decrypt(value)
}
